<script>
	import api from '../../api/index.js'
	import box from '@/mixins/box'
	import Calendar from '@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue'

	// 以下代码非本人写
	export default {
		components: {
			Calendar
		},
		mixins: [box],
		data() {
			return {
				noClick: true, //放连点
				min_multiple: 1,
				blindBoxDetail: {
					id: '',
					cat_id: '',
					max_multiple: 1,
					blind_box_prize: [],
				},
				autoplay: true,
				interval: 6000,
				duration: 1000,
				index: 0,
				goods_prize: 0,
				goods_title: '',
				prizeStatus: false,
				payStatus: false,
				shadeStatus: false,
				agreeStatus: false,
				animationStatus: false,
				levelId: 1,
				prizeData: [],
				payMode: 1,
				multiple: 1,

				tabId: 1,
				levelData: [{
						id: '',
						title: '全部'
					},
					{
						id: 4,
						title: '传说'
					},
					{
						id: 3,
						title: '史诗'
					},
					{
						id: 2,
						title: '稀有',
					},
				],
				logData: [],
				refreshStatus: false,
				page: 1,
				last_page: 1,
				selectLevelId: '',

				token: '',
				coupon_amount: 0,
				couponData: [],
				couponStatus: false,
				coupon_id: '', // 最终选择的优惠券
				selected_coupon_id: '',
				selected_coupon_amount: 0,
				last_times: 0,
				current: 0,

				point_price: 0,
				user_point: 0,

				barrageData: [],
				timer: null,
				barrage_index: 0,

				level_1_prize: [],
				level_2_prize: [],
				level_3_prize: [],
				level_4_prize: [],
				prizeList: [],
				drawStatus: true,

				pay_more_mode: 0,
				pay_mode_list: [],
				// 是否是多支付
				is_pay_more: false,
				// 多支付差额
				difference_amount: 0,
				// 显示更多充钱按钮
				showMoreBtn: false,
				openPayList: [{
						id: 1,
						num: 1,
					},
					{
						id: 2,
						num: 3,
					},
					{
						id: 3,
						num: 5,
					},
					{
						id: 4,
						num: 12
					}
				],
				openMorePayList: [{
						id: 4,
						num: 10,
					},
					{
						id: 5,
						num: 30,
					},
					{
						id: 6,
						num: 50,
					},
				],
				showHistory: false,
				showMore: false,
				toplist: [], //弹幕list
			}
		},
		computed: {
			drawNum() {
				switch (this.payMode) {
					case 1:
						return 1
					case 2:
						return 3
					case 3:
						return 5
					case 4:
						return 12
					case 5:
						return 30
					case 6:
						return 50
				}
			},
			pay_amount() {
				// const price = this.getPrice()
				let balance_price = this.total_amount - this.coupon_amount - this.point_price
				return balance_price > 0 ? balance_price.toFixed(2) : 0
			},
			total_amount() {
				const price = this.getPrice()
				return (price * this.multiple).toFixed(2)
			},
		},

		watch: {
			multiple(newVal) {
				this.getPriceSpread()
			},
		},

		onLoad(option) {
			// #ifdef MP-WEIXIN
			this.pay_mode_list.push({
				icon: 'https://www.dingxians.cn/upload/images/common/wechat.png',
				name: '微信'
			})
			// #endif

			// #ifndef MP-WEIXIN
			this.pay_mode_list.push({
				icon: 'https://www.dingxians.cn/upload/images/common/alipay.png',
				name: '支付宝'
			})
			// #endif
			this.blindBoxDetail.id = option.id
			this.getData()
		},
		onShow() {
			this.drawStatus = true
			this.token = uni.getStorageSync('token')
			this.selected_coupon_id = ''
			this.selected_coupon_amount = 0
			this.coupon_id = ''
			this.coupon_amount = 0
			if (this.token) {
				// 获取优惠券
				this.getCoupon()
				this.getUser()
			}
			this.getBarrage();
		},
		methods: {
			zhankai(item) {
				item.show = !item.show

				console.log(item.show)
			},
			getPrice() {
				return this.blindBoxDetail.price * this.drawNum
			},
			getBarrage() {
				api.blindBox
					.barrage(this.blindBoxDetail.id)
					.then((res) => {
						this.toplist = res.data.concat(res.data);
					})
			},

			getCoupon() {
				api.userCoupons
					.show({
						blind_box_id: this.blindBoxDetail.id,
						multiple: this.multiple,
						pay_mode: this.payMode,
					})
					.then((res) => {
						if (res.code == 200) {
							this.couponData = res.data.data
						}
					})
					.catch((error) => {
						console.log(error)
					})
			},
			getUser() {
				api.users
					.show({
						type: 'simple'
					})
					.then((res) => {
						if (res.code == 200) {
							this.user_point = res.data.point
							this.point_price = this.total_amount - this.coupon_amount
							this.point_price = this.user_point > this.point_price ? this.point_price : this.user_point
						}
					})
					.catch((error) => {
						console.log(error)
					})
			},
			changePirze(id) {
				for (var i = 0; i < this.blindBoxDetail.blind_box_prize.length; i++) {
					if (this.blindBoxDetail.blind_box_prize[i].id == id) {
						this.current = i
						break
					}
				}
			},
			useCoupon(item, index) {
				this.selectCoupon(item, index)
				this.confirmCoupon()
			},
			selectCoupon(item, index) {
				for (var i = 0; i < this.couponData.length; i++) {
					this.couponData[i].selected = false
				}
				item.selected = !item.selected
				this.selected_coupon_id = item.id
				this.selected_coupon_amount = item.amount
				this.$set(this.couponData, index, item)
			},
			// 确定优惠券
			confirmCoupon() {
				this.coupon_id = this.selected_coupon_id
				this.coupon_amount = this.selected_coupon_amount
				// 多支付的金额减去优惠后的价格
				/*this.difference_amount -= this.selected_coupon_amount*/
				this.couponStatus = false

				this.point_price = this.total_amount - this.coupon_amount
				this.point_price = this.user_point > this.point_price ? this.point_price : this.user_point

				this.getPriceSpread()
			},
			lower() {
				if (this.page > this.last_page) {
					this.show('没有更多数据了')
					return
				}
				this.page++
				this.getLog(1)
			},
			refresh() {
				this.refreshStatus = true
				this.page = 1
				this.getLog(2)
			},
			back() {
				uni.navigateBack()
			},
			play() {
				this.header('/packageB/content/playRule')
			},
			changeLevel(level_id) {
				if (this.levelId != level_id) {
					this.levelId = level_id
					this.prizeData = this.blindBoxDetail.blind_box_prize.filter((item) => {
						return item.level_id == level_id
					})
				}
			},
			// 同意用户协议
			changeAgree() {
				this.agreeStatus = !this.agreeStatus
			},
			showPrize() {
				this.prizeStatus = true
				this.shadeStatus = true
			},
			showCoupon() {
				this.couponStatus = true
				this.shadeStatus = true
			},
			closeCoupon() {
				this.couponStatus = false
			},
			closePrize() {
				this.prizeStatus = false
				this.shadeStatus = false
			},
			closeShade() {
				this.prizeStatus = false
				if (!this.couponStatus) {
					this.payStatus = false
					this.shadeStatus = false
				}
				this.couponStatus = false
			},
			getData() {
				uni.showLoading({
					title: '数据加载中',
				})
				api.blindBox
					.show(this.blindBoxDetail.id)
					.then((res) => {
						uni.hideLoading()
						if (res.code === 200) {
							console.log(res, "详情")
							this.blindBoxDetail = res.data.data
							// console.log(this.blindBoxDetail)
							this.goods_prize = this.blindBoxDetail.blind_box_prize[0].price
							this.goods_title = this.blindBoxDetail.blind_box_prize[0].title

							// this.prizeData = this.blindBoxDetail.blind_box_prize.filter(item => {
							// 	return item.level_id == 1
							// })
							this.level_1_prize = this.blindBoxDetail.blind_box_prize.filter((item) => {
								return item.level_id == 1
							})
							this.level_2_prize = this.blindBoxDetail.blind_box_prize.filter((item) => {
								return item.level_id == 2
							})
							this.level_3_prize = this.blindBoxDetail.blind_box_prize.filter((item) => {
								return item.level_id == 3
							})
							this.level_4_prize = this.blindBoxDetail.blind_box_prize.filter((item) => {
								return item.level_id == 4
							})
							this.prizeList = [this.level_4_prize, this.level_3_prize, this.level_2_prize, this
								.level_1_prize
							]
						}
					})
					.catch((error) => {
						console.log(error)
					})
			},
			changeBox(e) {
				let index = e.detail.current
				this.goods_prize = this.blindBoxDetail.blind_box_prize[index].price
				this.goods_title = this.blindBoxDetail.blind_box_prize[index].title
			},
			openPay(pay_mode) {
				if (!this.token) {
					this.header('/pages/user/login')
					return
				}
				// this.payStatus = true
				// this.shadeStatus = true
				this.$refs.payPopup.open('bottom')
				this.payMode = pay_mode
				// 计算价格
				this.coupon_amount = 0
				this.selected_coupon_amount = 0
				this.coupon_id = ''
				this.selected_coupon_id = ''
				this.point_price = this.total_amount - this.coupon_amount
				this.point_price = this.user_point > this.point_price ? this.point_price : this.user_point

				this.is_pay_more = false
				this.difference_amount = 0

				this.getCoupon()
				this.getPriceSpread()
			},
			getPriceSpread() {
				api.blindBox
					.priceSpread({
						blind_box_id: this.blindBoxDetail.id,
						pay_mode: this.payMode,
						multiple: this.multiple,
						coupon_id: this.coupon_id,
						point_price: this.point_price,
						version: 1,
					})
					.then((res) => {
						if (res.code === 401) {
							this.is_pay_more = true
							this.difference_amount = res.data.difference_amount
						} else if (res.code === 200) {
							this.is_pay_more = false
							this.difference_amount = 0
						}
					})
			},
			closePay() {
				this.payStatus = false
				this.shadeStatus = false
			},
			navigatePay() {
				// 创建充值订单
				let pay_type = this.pay_more_mode + 1
				api.rechargeOrders
					.store({
						type: pay_type,
						id: 0,
						amount: this.difference_amount
					})
					.then((res) => {
						if (res.code === 200) {
							// 微信支付
							if (pay_type == 1) {
								let pay_data = res.data.data
								// #ifdef MP-WEIXIN
								uni.requestPayment({
									provider: 'wxpay',
									timeStamp: pay_data.timeStamp.toString(),
									nonceStr: pay_data.nonceStr,
									signType: 'MD5',
									package: pay_data.package,
									paySign: pay_data.paySign,
									success: (res) => {
										this.show('支付成功')
										setTimeout(() => {
											// this.getUser()
											this.is_pay_more = false
											this.difference_amount = 0
											this.draw()
										}, 500)
									},
									fail: (err) => {
										console.log(err)
									},
								})
								// #endif
								// #ifdef APP-PLUS
								uni.requestPayment({
									provider: 'wxpay',
									orderInfo: {
										appid: pay_data.appid, // 微信开放平台 - 应用 - AppId，注意和微信小程序、公众号 AppId 可能不一致
										noncestr: pay_data.noncestr, // 随机字符串
										package: pay_data.package, // 固定值
										partnerid: pay_data.partnerid, // 微信支付商户号
										prepayid: pay_data.prepayid, // 统一下单订单号
										timestamp: pay_data.timestamp, // 时间戳（单位：秒）
										sign: pay_data.sign, // 签名，这里用的 MD5/RSA 签名
									},
									success: (res) => {
										this.show('支付成功')
										setTimeout(() => {
											// this.getUser()
											this.is_pay_more = false
											this.difference_amount = 0
											this.draw()
										}, 500)
									},
									fail: (error) => {
										console.log(error)
									},
								})
								// #endif
							} else if (pay_type == 2) {
								let pay_data = res.data.data
								uni.requestPayment({
									provider: 'alipay',
									orderInfo: pay_data,
									success: (res) => {
										this.show('支付成功')
										setTimeout(() => {
											// this.getUser()
											this.is_pay_more = false
											this.difference_amount = 0
											this.draw()
										}, 500)
									},
									fail: (error) => {
										console.log(error)
									},
								})
							}
						}
					})
					.catch((error) => {
						console.log(error)
					})
			},
			draw() {
				if (!this.agreeStatus) {
					this.show('请先同意用户协议')
					return
				}
				if (this.is_pay_more) {
					// 跳轉支付頁面
					this.navigatePay()
					return
				}
				this.drawStatus = false
				uni.showLoading({
					title: '抽奖中',
				})
				let params = {
					blind_box_id: this.blindBoxDetail.id,
					pay_mode: this.payMode,
					multiple: this.multiple,
					coupon_id: this.coupon_id,
					point_price: this.point_price,
					version: 1,
				}
				console.log(params, "paramsparams")
				api.blindBox
					.draw(params)
					.then((res) => {
						console.log(res, "抽奖")
						uni.hideLoading()
						if (res.code === 200) {
							if (res.data.status == 1) {
								this.header(
									`/pages/index/draw?box_order_id=${res.data.box_order_id}&box_id=${this.blindBoxDetail.id}&pay_mode=${this.payMode}`,
								)
							} else if (res.data.status == 0) {
								this.show(res.msg)
								setTimeout(() => {
									this.header(`/pages/user/recharge`)
								}, 500)
							}
						} else if (res.code === 401) {
							this.is_pay_more = true
							this.difference_amount = res.data.difference_amount
						}
						this.drawStatus = true
					})
					.catch((error) => {
						console.log(error)
					})
			},
			changeLog() {
				this.showHistory = !this.showHistory

				if (!this.showHistory) {
					return
				}

				this.tabId = 2
				this.page = 1
				// this.selectLevelId = ''
				this.getLog(2)
			},
			getLog(type) {
				uni.showLoading({
					title: '数据加载中',
				})
				api.blindBoxOrderPrizeLogs
					.log({
						blind_box_id: this.blindBoxDetail.id,
						// page: this.page,
						// level_id: this.selectLevelId,
					})
					.then((res) => {
						uni.hideLoading()
						if (res.code === 200) {
							res.data.data.forEach((item) => (item.show = false))
							this.logData = res.data.data
							this.refreshStatus = false
						}
					})
					.catch((error) => {
						console.log(error)
					})
			},
			getPrize() {
				this.tabId = 1
			},
			changeSelectLevel(id) {
				if (this.selectLevelId != id) {
					this.page = 1
					this.selectLevelId = id
					this.getLog(2)
				}
			},
		},
	}
</script>

<template>
	<view class="detail-container">
		<my-header></my-header>
		<my-content>
			<view class="box-header">
				<image class="box-img" mode="aspectFit" :src="blindBoxDetail.image"></image>
				<text class="box-name">{{ blindBoxDetail.name }}</text>

				<text @click="play" class="box-rule">玩法规则</text>
			</view>
			<!-- 最近开出+弹幕List -->
			<view class="zuijin_box">
				<view class="zuijin_left_box">
					<view class="head_wrap" style=";z-index: 99;overflow: hidden;">
						<view class="head_box">
							<view class="record_box" v-for="(item, index) in toplist" :key="index">
								<view class="record_item">
									<image :src="item.avatar" mode="aspectFill" class="head_portrait"></image>
									<view class="record_title">
										{{ item.nickname }}开出了
										<text class="name" :style="{ background: item.level_color }">{{
					item.level_name }}</text>

										{{ (item.blind_box_prize_name) }}
									</view>
									<view class="record_r">
										<view class="record_text" v-if="item.pay_mode">
											×{{ item.num }}
										</view>
										<image :src="item.blind_box_prize_image" mode="aspectFill" class="goods">
										</image>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="box-history">
				<text class="box-title">包含以下赏品</text>
				<text class="box-btn" @click="changeLog">
					{{ showHistory ? '赏品预览' : '抽赏记录' }}
				</text>
			</view>
			<view class="box-pro item-bg">
				<view class="box-pro-item" :style="{ color: item.level_color }"
					v-for="item in blindBoxDetail.probability" :key="item.id" @click="changeSelectLevel(item.id)">
					<view class="pro-content">
						<view class="dot" :style="{ backgroundColor: item.level_color }"></view>
						<view class="pro-text">{{ item.pro }}</view>
						<view class="pro-name">{{ item.level_name }}</view>
					</view>
				</view>
			</view>

			<view v-if="!showHistory" class="prize-content">
				<view class="prize-list" v-for="(prize, index) in prizeList" :key="index">
					<view class="prize-item"
						:style="{ backgroundImage: `url(https://www.dingxians.cn/upload/images/index/bg-box-${item.level_id}.png)` }"
						v-for="item in prize" :key="item.id">
						<view class="prize-img">
							<image :src="item.image" mode="heightFix"></image>
						</view>
						<!-- #ifdef APP-PLUS-->
						<view class="prize-name" style="text-align: center;">¥：{{ item.price }}</view>
						<!-- #endif -->
						<!-- #ifdef  MP-WEIXIN-->
						<view class="prize-name" style="text-align: center;">概率：{{ (item.probability * 1) + '%' }}
						</view>
						<!-- #endif -->

						<view class="prize-name">{{ item.title }}</view>
					</view>
					<view style="flex: 0 0 30.33%"></view>
				</view>
				<view style="height: 300rpx"></view>
			</view>

			<view class="draw-dialog-content" v-show="showHistory">
				<view class="dialog-bg">
					<!-- <view class="dialog-header">
            <text class="circle"></text>
            中奖记录
            <text class="circle"></text>
          </view> -->
					<view class="dialog-content">
						<view class="history-list">
							<view class="history-item" v-for="(item, position) in logData" :key="item.id"
								@click="item.show = !item.show">
								<view class="history-child-item" v-if="index === 0 || item.show"
									v-for="(child, index) in item.prizes" :key="child.id"
									:style="{ backgroundImage: `url(https://www.dingxians.cn/upload/images/index/bg-history-${item.id}.png)` }">
									<view class="history-left">
										<image class="user-avatar" :src="child.avatar"></image>
										<view class="user-info">
											<view class="user-name">{{ child.nickname }}</view>
											<view class="history-time">{{ child.created_at }}</view>
										</view>
										<view class="history-num">{{ child.num }}</view>
										<!-- #ifdef APP-PLUS -->
										<view @click.stop="item.show = !item.show" class="history-status" v-if="index === 0">
										
										
											{{ item.show ? '隐藏' : '展开' }}
											<image v-if="item.show" class="status"
												src="https://hs.qixdian.cn/upload/images/open/up.png"
												mode="scaleToFill" />
											<image v-else class="status"
												src="https://hs.qixdian.cn/upload/images/open/down.png"
												mode="scaleToFill" />
										</view>
										<!-- #endif -->
										<!-- #ifdef MP-WEIXIN -->
										<view @click="zhankai(item)" class="history-status" v-if="index === 0">
										
										
											{{ item.show ? '隐藏' : '展开' }}
											<image v-if="item.show" class="status"
												src="https://hs.qixdian.cn/upload/images/open/up.png"
												mode="scaleToFill" />
											<image v-else class="status"
												src="https://hs.qixdian.cn/upload/images/open/down.png"
												mode="scaleToFill" />
										</view>
										<!-- #endif -->
									</view>
									<view class="history-right">
										<image class="prize-type"
											:src="`https://hs.qixdian.cn/upload/images/open/bg-level${item.id}.png`">
										</image>
										<view class="prize-name">{{ child.blind_box_prize_name }}</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</my-content>

		<view class="open-draw-group">
			<view class="groups">
				<view @click="openPay(item.id)" class="open-item" v-for="item in openPayList" :key="item.id">
					<image class="open-draw-btn"
						:src="`https://www.dingxians.cn/upload/images/index/bg-open-${item.num}.png`">
					</image>
					<text class="open-price">￥{{ (blindBoxDetail.price * item.num).toFixed(2) }}</text>
				</view>
			</view>
		</view>

		<uni-popup ref="payPopup" type="dialog">
			<view class="pay-popup">
				<view class="pay-header">确认订单</view>
				<view class="pay-goods">
					<image class="goods-img" :src="blindBoxDetail.image" mode="aspectFit"></image>
					<view class="goods-info">
						<text class="goods-name">{{ blindBoxDetail.name }}</text>
						<text class="goods-price">￥{{ blindBoxDetail.price }}</text>
					</view>
					<view class="goods-num">X{{ drawNum }}</view>
				</view>
				<view class="pay-deduction">
					<view class="pay-deduction-item" @click="showCoupon">
						<view class="pay-deduction-left">
							<image class="pay-deduction-icon"
								src="https://www.dingxians.cn/upload/images/common/ic-coupon.png" mode="aspectFit">
							</image>
							<text class="pay-deduction-name">优惠券</text>
						</view>
						<view class="pay-deduction-right">
							<text class="pay-deduction-name" v-if="couponData.length > 0">
								{{ coupon_amount > 0 ? '-' + coupon_amount : '选择优惠券>' }}
							</text>
							<text class="pay-deduction-name" v-else>暂无优惠券</text>
						</view>
					</view>
					<view class="pay-deduction-item">
						<view class="pay-deduction-left">
							<image class="pay-deduction-icon"
								src="https://www.dingxians.cn/upload/images/shop/money.png" mode="aspectFit"></image>
							<text class="pay-deduction-name">金币支付</text>
						</view>
						<view class="pay-deduction-right">
							<text class="pay-amount">{{ pay_amount }}</text>
						</view>
					</view>
					<view class="pay-deduction-item">
						<view class="pay-deduction-left">
							<image class="pay-deduction-icon"
								src="https://www.dingxians.cn/upload/images/index/ic-diamond.png" mode="aspectFit">
							</image>
							<text class="pay-deduction-name">钻石抵扣</text>
						</view>
						<view class="pay-deduction-right">
							<text class="pay-amount">{{ parseFloat(point_price).toFixed(2) }}</text>
						</view>
					</view>
					<view class="pay-deduction-item">
						<view class="pay-deduction-left">
							<text>总计：</text>
						</view>
						<view class="pay-deduction-right">
							<text class="pay-amount">{{ total_amount }}</text>
						</view>
					</view>
				</view>
				<view class="pay-deduction" v-if="is_pay_more">
					<view class="pay-mode-header">支付方式</view>
					<view class="pay-deduction-item" @click="pay_more_mode = index"
						v-for="(item, index) in pay_mode_list" :key="index">
						<view class="pay-deduction-left">
							<image class="pay-deduction-icon" :src="item.icon" mode="aspectFit"></image>
							<text class="pay-deduction-name">{{ item.name }}</text>
						</view>
						<view class="pay-deduction-right">
							<image class="selector" v-if="pay_more_mode === index"
								src="https://www.dingxians.cn/upload/images/common/selected.png"></image>
							<image class="selector" v-else
								src="https://www.dingxians.cn/upload/images/common/unselected.png"></image>
						</view>
					</view>
				</view>

				<view class="agree-box">
					<view class="agree-item">
						<image @click="agreeStatus = !agreeStatus" v-if="agreeStatus" class="selector"
							src="https://www.dingxians.cn/upload/images/common/selected.png"></image>
						<image @click="agreeStatus = !agreeStatus" v-else class="selector"
							src="https://www.dingxians.cn/upload/images/common/unselected.png"></image>
						我已满18周岁，已阅读并同意
						<navigator class="navigator" url="/packageB/content/user">《用户协议》</navigator>
					</view>
					<view>开箱说明：盲盒存在概率性，请谨慎购买，未满18周岁未成年人禁止参与</view>
				</view>
				<view class="pay-bottom">
					<view class="pay-bottom-left">
						合计:
						<text class="price-total">￥{{ difference_amount }}</text>
					</view>
					<view class="pay-bottom-right">
						<button class="pay-btn btn-primary" @click="$noMultipleClicks(draw)">购买支付</button>

					</view>
				</view>

				<image @click="$refs.payPopup.close('dialog')"
					src="https://www.dingxians.cn/upload/images/shop/close-btn.png" class="close-btn"></image>
			</view>
		</uni-popup>

		<!-- 优惠券弹窗 -->
		<view class="coupon_pop" :class="[couponStatus ? 'show' : 'hidden']">
			<view class="coupon_header">
				<image @click="closeCoupon()" src="https://www.dingxians.cn/upload/images/shop/close-btn.png"
					class="coupon_close"></image>
				<view class="coupon_header_title">选择优惠券</view>
			</view>

			<view class="coupon_content">
				<view class="coupon_item" @click="selectCoupon(item, index)" v-for="(item, index) in couponData"
					:key="item.id">
					<view class="coupon_right">
						<view class="coupon_title">{{ item.name }}</view>
						<view class="coupon-info">
							<view class="coupon_remark">{{ item.remark }}</view>
							<view class="coupon_min_amount" v-if="item.min_amount > 0">满{{ item.min_amount }}可用</view>
							<view class="coupon_min_amount" v-else>无门槛</view>
						</view>
						<view class="coupon_bottom">
							<view class="created_at">有效期至{{ item.expired_at }}</view>
						</view>
					</view>
					<view class="coupon_left">
						<view class="coupon_amount">
							<view class="coupon_amount_icon">￥</view>
							<view>{{ item.amount }}</view>
						</view>
						<view class="coupon_btn btn-primary" @click="useCoupon(item, index)">立即使用</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<style scoped lang="scss">
	.detail-container {
		height: 100vh;
		background: url('https://www.dingxians.cn/upload/images/common/bg.png') 100%/100% fixed;
		overflow: hidden;

		.box-header {
			margin: 30rpx auto;
			width: 710rpx;
			height: 260rpx;
			background: url('https://www.dingxians.cn/upload/images/index/bg-box-header.png') 100%/100% no-repeat;
			display: flex;
			align-items: center;
			box-sizing: border-box;
			padding: 0 30rpx;
			position: relative;

			.box-img {
				width: 170rpx;
				height: 170rpx;
				border-radius: 14rpx;
			}

			.box-name {
				color: #fff;
				font-size: 40rpx;
				margin-left: 30rpx;
				font-family: 'youshe', serif;
			}

			.box-rule {
				position: absolute;
				right: 30rpx;
				top: 30rpx;
				color: white;
			}
		}

		.zuijin_box {
			width: 100%;
			height: 64rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding-right: 22rpx;

			.zuijin_left_box {
				width: 100%;
				height: 100%;
				// background-color: #fff;

				.head_wrap {
					width: 100%;

					.head_box {
						height: 58rpx;
						display: flex;
						align-items: center;
						// margin-top: 580rpx;

						.record_box {
							display: flex;
							align-items: center;
							height: 120rpx;
							padding-left: 100rpx;
							animation: record_box1 50s linear infinite both;
							// animation: record_box1 6s linear 0s infinite;
							color: #ffffff;

							.record_item {
								display: flex;
								align-items: center;
								width: 460rpx;
								height: 50rpx;
								background: rgba(255, 255, 255, 0.15);
								border-radius: 27rpx;

								.head_portrait {
									width: 46rpx;
									height: 46rpx;
									border-radius: 50%;
									margin-right: 26rpx;
									margin-left: 10rpx;
								}

								.record_title {
									width: 360rpx;
									flex: 1;
									font-size: 18rpx;
									overflow: hidden;
									text-overflow: ellipsis;
									white-space: nowrap;

									.name {
										width: 70rpx;
										height: 35rpx;
										border-radius: 6rpx;
										padding: 0 10rpx;
									}
								}

								.record_r {
									flex-shrink: 0;
									display: flex;
									align-items: center;
								}

								.record_text {
									width: 90rpx;
									height: 40rpx;
									font-size: 30rpx;
									font-weight: bold;
									margin-left: 70rpx;
									margin-right: 10rpx;
								}

								.goods {
									width: 45rpx;
									height: 46rpx;
									border-radius: 50%;
									margin-right: 10rpx;
								}
							}
						}


						@keyframes record_box1 {

							0% {
								transform: translate3d(0, 0, 0);
							}

							100% {
								transform: translate3d(-10000rpx, 0, 0);
							}
						}
					}
				}
			}

			.zuijin_right_box {
				width: 208rpx;
				height: 100%;

				image {
					width: 100%;
					height: 100%;
				}
			}
		}


		.box-history {
			width: 710rpx;
			margin: 20rpx auto;
			display: flex;
			align-items: center;
			justify-content: flex-end;
			font-family: 'youshe', serif;
			font-weight: 400;
			font-size: 36rpx;
			color: #ffffff;
			line-height: 44rpx;
			text-shadow: 0 0 20px #45f5ff;
			text-align: left;
			font-style: normal;
			text-transform: none;

			.box-title {
				margin-right: 60rpx;
			}

			.box-btn {
				width: 350rpx;
				height: 80rpx;
				text-align: center;
				line-height: 80rpx;
				background: rgba(0, 0, 0, 0.37);
				box-shadow: inset 0 0 36rpx 0 rgba(0, 220, 255, 0.45);
				border-radius: 10rpx 10rpx 10rpx 10rpx;
			}
		}

		.box-pro {
			width: 710rpx;
			margin: 0 auto;
			color: white;

			display: flex;
			align-items: center;
			justify-content: space-around;
			box-sizing: border-box;
			padding: 20rpx 0;

			text-align: center;

			.pro-content {
				position: relative;
			}

			.dot {
				display: inline-block;
				width: 20rpx;
				height: 20rpx;
				border-radius: 10rpx;
				position: absolute;
				left: -25rpx;
				top: 50%;
			}
		}

		.prize-content {
			overflow-y: scroll;
		}

		.prize-list {
			width: 710rpx;
			margin: 30rpx auto;
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;

			.prize-item {
				width: 225rpx;
				height: 300rpx;
				background-size: 100% 100%;
				margin-bottom: 10rpx;
				box-sizing: border-box;
				padding-top: 40rpx;


				.prize-img {
					display: block;
					width: 150rpx;
					max-height: 180rpx;
					margin: auto;

					image {
						display: block;
						margin: auto;
						max-width: 150rpx;
						max-height: 160rpx;
					}
				}

				.prize-name {
					color: white;
					font-size: 18rpx;
					display: -webkit-box;
					-webkit-line-clamp: 1;
					-webkit-box-orient: vertical;
					overflow: hidden;
					box-sizing: border-box;
					margin: 0 20rpx 0 40rpx;
				}
			}
		}

		.open-draw-group {
			position: fixed;
			left: 30rpx;
			bottom: 30rpx;
			width: 690rpx;

			.groups {
				display: flex;
				align-items: center;
				justify-content: space-around;

				&.more {
					justify-content: flex-end;
				}
			}

			.open-draw-btn {
				width: 134rpx;
				height: 156rpx;
			}

			.open-item {
				position: relative;
			}

			.open-price {
				position: absolute;
				left: 50%;
				transform: translateX(-50%);
				bottom: 50rpx;
				color: white;
				font-size: 20rpx;
			}
		}

		.pay-popup {
			background-color: #030522;
			color: white;
			padding: 30rpx;
			position: relative;

			.pay-header {
				text-align: center;
			}

			.pay-goods {
				display: flex;
				margin-top: 30rpx;

				.goods-img {
					width: 158rpx;
					height: 158rpx;
					border-radius: 14rpx;
				}

				.goods-info {
					flex: 1;
					margin: 0 30rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-around;

					.goods-name {
						font-size: 32rpx;
					}

					.goods-price {
						color: #ee5093;
						font-size: 36rpx;
					}
				}
			}

			.pay-deduction {
				padding: 10rpx 0;
				border-bottom: 2rpx solid rgba(255, 255, 255, 0.22);

				.pay-deduction-item {
					display: flex;
					justify-content: space-between;
					padding: 10rpx 0;
					align-items: center;

					.pay-deduction-left {
						.pay-deduction-icon {
							width: 46rpx;
							height: 42rpx;
							margin-right: 20rpx;
							vertical-align: middle;
						}
					}

					.pay-deduction-right {
						.pay-amount {
							color: #ee5093;
						}

						.selector {
							width: 32rpx;
							height: 32rpx;
						}
					}
				}
			}

			.agree-box {
				text-align: center;
				font-size: 20rpx;

				.agree-item {
					display: flex;
					justify-content: center;
					align-items: center;

					.selector {
						width: 32rpx;
						height: 32rpx;
						margin-right: 10rpx;
					}

					.navigator {
						color: #ee5093;
					}
				}
			}

			.pay-bottom {
				margin-top: 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.price-total {
					color: #ee5093;
					font-size: 40rpx;
				}

				.pay-btn {
					color: white;
					width: 232rpx;
					height: 72rpx;
					line-height: 72rpx;
				}
			}

			.close-btn {
				width: 28rpx;
				height: 28rpx;
				position: absolute;
				right: 30rpx;
				top: 30rpx;
			}
		}

		.coupon_pop {
			transition: all 0.6s; //这是滑入划出的动画
			position: fixed;
			width: 100%;
			height: 730rpx;
			bottom: -100%;
			border-top-right-radius: 20rpx;
			border-top-left-radius: 20rpx;
			background-color: #030522;
			z-index: 1502;
			max-height: 80%;

			/* background: linear-gradient(to top, #fefeff, #ceb8ff); */

			&.show {
				bottom: 0;
			}

			&.hidden {
				bottom: -100%;
			}

			display: flex;
			flex-direction: column;

			.coupon_header {
				display: flex;
				align-items: center;
				flex-direction: column;
				margin-top: 25rpx;
				justify-content: center;
				height: 80rpx;
				position: relative;

				.coupon_close {
					position: absolute;
					right: 30rpx;
					top: -150%;
					width: 36rpx;
					height: 36rpx;
					z-index: 10000;
				}

				.coupon_header_title {
					font-size: 36rpx;
					font-weight: bold;
					margin-bottom: 20rpx;
					color: white;
				}
			}

			.coupon_content {
				display: flex;
				flex-direction: column;
				width: 715rpx;
				margin: 30rpx auto 0;
				height: 100%;
				/* max-height: 500rpx; */
				overflow: scroll;

				// border: 1rpx solid red;
				.coupon_item {
					display: flex;
					margin-bottom: 20rpx;
					height: 200rpx;
					border-radius: 10rpx;
					/* background-color: #fff; */
					background-image: url('https://www.dingxians.cn/upload/images/user/bg-coupon-item.png');
					background-size: 100% 100%;
					color: white;

					// overflow: hidden;
					.coupon_left {
						display: flex;
						flex-direction: column;
						justify-content: center;
						align-items: center;
						/* background-color: #a361f6; */
						height: 200rpx;
						width: 180rpx;
						margin-right: 20rpx;
						border-top-left-radius: 10rpx;
						border-bottom-left-radius: 10rpx;
						position: relative;
						z-index: 2;

						.coupon_bg {
							position: absolute;
							top: 0;
							left: 0;
							height: 200rpx;
							width: 180rpx;
							border-top-left-radius: 10rpx;
							border-bottom-left-radius: 10rpx;
							z-index: -1;
						}

						.coupon_amount {
							font-size: 46rpx;
							color: white;
							font-weight: bold;
							display: flex;
							align-items: baseline;

							.coupon_amount_icon {
								font-size: 48rpx;
							}
						}

						.coupon_min_amount {
							font-size: 24rpx;
						}

						.coupon_btn {
							margin-top: 10rpx;
							color: white;
							width: 148rpx;
							height: 48rpx;
							line-height: 48rpx;
							background-size: 100% 100%;
							text-align: center;
						}
					}

					.coupon_right {
						margin-left: 20rpx;
						height: 100%;
						display: flex;
						flex-direction: column;
						justify-content: center;
						flex: 1;

						.coupon-info {
							display: flex;
							margin-left: 24rpx;
							color: white;
							font-size: 24rpx;
						}

						.coupon_title {
							font-size: 32rpx;
							font-family: 'youshe';
							margin-left: 24rpx;
						}

						.coupon_remark {
							font-size: 26rpx;
							margin-right: 10rpx;
						}

						.coupon_bottom {
							display: flex;
							align-items: center;
							justify-content: space-between;
							width: 370rpx;
							height: 40rpx;
							box-sizing: border-box;
							padding-left: 24rpx;
							line-height: 40rpx;
							background-size: 100% 100%;

							.created_at {
								font-size: 24rpx;
							}

							.use {
								border-radius: 20rpx;
								padding: 10rpx 20rpx;
								font-size: 24rpx;
								background-color: #a361f6;
								margin-right: 10rpx;
							}
						}
					}

					.coupon_select_box {
						display: flex;
						justify-content: flex-end;
						align-items: center;

						.coupon_select_icon {
							width: 40rpx;
							height: 40rpx;
							margin-right: 20rpx;
						}
					}
				}
			}

			/* .coupon_btn {
      width: 600rpx;
      height: 100rpx;
      line-height: 100rpx;
      text-align: center;
      background-color: #a361f6;
      border-radius: 10rpx;
      margin: 20rpx auto;

      &.disable {
        background-color: #e7e7e7;
        color: #666;
      }
    } */
		}

		.draw-dialog-content {
			color: white;
			box-sizing: border-box;
			width: 690rpx;
			position: relative;
			margin: 0 auto;
			flex: 1;
			overflow-y: scroll;
			padding-bottom: 100rpx;

			&.mask {
				background-color: rgba(0, 0, 0, 0.8);
				padding: 30rpx;
			}

			.dialog-header {
				display: flex;
				justify-content: center;
				align-items: center;
				font-size: 40rpx;
				font-weight: bold;

				.circle {
					display: block;
					width: 10rpx;
					height: 10rpx;
					border-radius: 50%;
					background-color: white;
					margin: 0 20rpx;
				}
			}

			.dialog-content {
				font-size: 26rpx;
				padding: 30rpx 0;
				height: 100%;

				.content-line {
					line-height: 55rpx;
				}

				.history-list {
					.history-item {
						margin-bottom: 30rpx;

						.history-child-item {
							padding: 10rpx 0;
							display: flex;
							justify-content: space-between;
							align-items: center;
							position: relative;
							height: 155rpx;
							margin-bottom: 30rpx;
							background-size: 100% 100%;

							.history-left {
								display: flex;
								align-items: center;
								white-space: nowrap;

								.history-status {
									z-index: 8;
									position: absolute;
									right: 30rpx;
									bottom: 0;
									font-size: 24rpx;
									color: black;
									padding: 4rpx 7rpx;
									border-radius: 5rpx;
									background-color: #ffba01;
									vertical-align: middle;
								}

								.status {
									width: 20rpx;
									height: 11rpx;
								}

								.history-num {
									position: absolute;
									top: 0;
									left: 0;
									font-size: 22rpx;
									color: black;
									background-color: #ffba01;
									border-radius: 5rpx;
									padding: 4rpx 7rpx;
								}

								.user-avatar {
									width: 80rpx;
									height: 80rpx;
									margin-left: 50rpx;
								}

								.user-info {
									margin-left: 20rpx;

									.user-name {
										font-size: 26rpx;
									}

									.history-time {
										font-size: 20rpx;
										margin-top: 10rpx;
									}
								}
							}

							.history-right {
								flex: 1;
								overflow: hidden;
								text-align: end;
								margin-left: 20rpx;
								margin-right: 30rpx;

								.prize-type {
									width: 99rpx;
									height: 27rpx;
								}

								.prize-name {
									width: 100%;
									white-space: nowrap;
									overflow: hidden;
									text-overflow: ellipsis;
									font-size: 20rpx;
									margin-top: 10rpx;
								}
							}
						}
					}
				}

				.prize-list {
					max-height: 700rpx;
					overflow-y: scroll;

					.prize-item {
						display: flex;
						align-items: center;
						justify-content: space-between;

						.prize-img {
							width: 60rpx;
							height: 80rpx;
						}

						.draw-type {
							font-size: 28rpx;
							color: #01ffff;
							font-weight: bold;
							margin-left: 20rpx;
						}

						.prize-name {
							flex: 1;
							text-align: center;
							white-space: nowrap;
							text-overflow: ellipsis;
							overflow: hidden;
							font-size: 28rpx;
							margin: 0 5rpx;
						}

						.draw-pro {
							font-size: 26rpx;
							opacity: 0.5;
						}
					}
				}
			}

			.close-btn {
				position: absolute;
				width: 70rpx;
				height: 70rpx;
				bottom: -120rpx;
				left: 50%;
				transform: translateX(-50%);
			}
		}
	}
</style>